package cn.fintecher.gis.entity;

import cn.fintecher.gis.enums.CommonState;
import cn.fintecher.gis.enums.UserTitle;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * Created by ChenChang on 2018/9/4.
 */
@Entity
@Table(name = "operator")
@Data
@ApiModel(value = "operator", description = "操作员")
public class Operator extends BaseEntity {
    public Operator() {
        super();
    }

    public Operator(String id) {
        setId(id);
    }

    @ApiModelProperty(notes = "用户名")
    private String username;

    @ApiModelProperty(notes = "密码")
    private String password;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "depart_id")
    @ApiModelProperty(notes = "用户所在部门的id")
    private Department department;

    @ApiModelProperty(notes = "职称")
    @Enumerated(EnumType.STRING)
    private UserTitle userTitle;

    @ApiModelProperty(notes = "状态")
    @Enumerated(EnumType.STRING)
    private CommonState userStatus;

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinTable(name = "user_role", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
    @ApiModelProperty(notes = "用户所拥有的角色")
    private Set<RoleInfo> roles;

    @ApiModelProperty(notes = "创建时间")
    private Date createTime;
}
